#!/bin/bash
workdir=$(cd ${0%/*}/; pwd)
#echo ${workdir}
cd ${workdir}

SERVICE_NAME="mediaserz.service"
if systemctl is-active --quiet "$SERVICE_NAME"; then
    echo "服务 $SERVICE_NAME 正在运行."
    systemctl stop $SERVICE_NAME
    systemctl disable $SERVICE_NAME
fi

chmod +x mediaserz.sh
chmod +x mediaserz.service

cp -f mediaserz.sh /usr/bin/
cp -f mediaserz.service /lib/systemd/system/

systemctl daemon-reload
systemctl enable mediaserz
systemctl start mediaserz

echo "install mediaser OK ..."